﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AppFx
{
	public static class LinqExtender
	{
		public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
		{
			foreach (T item in source) { action(item); }
		}

		public static void ForEach<T>(this IEnumerable<T> source1, IEnumerable<T> source2, Action<T, T> action)
		{
			for (int i = 0; i < source1.Count(); i++)
			{
				action(source1.ElementAt(i), source2.ElementAt(i));
			}
		}

		public static IEnumerable<T> ForEach<T>(this IEnumerable<T> source, Func<T, T> function)
		{
			foreach (T item in source) { yield return function(item); }
		}
	}
}
